

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Data &mdash; RFML w/ PyTorch Software Documentation 1.0.0 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
        <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Notebook Utilities" href="nbutils.html" />
    <link rel="prev" title="Welcome to RFML with PyTorch’s documentation!" href="index.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> RFML w/ PyTorch Software Documentation
          

          
          </a>

          
            
            
              <div class="version">
                1.0.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#"> Data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#converters">Converters</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#module-rfml.data.converters.rml_2016">RML2016</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#module-rfml.data.dataset_builder">Dataset Builder</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-rfml.data.dataset">Dataset</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-rfml.data.encoder">Encoder</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-rfml.data.factory">Factory</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="nbutils.html"> Notebook Utilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="nn.html"> Neural Networks</a></li>
<li class="toctree-l1"><a class="reference internal" href="ptradio.html"> PyTorch Radio</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">RFML w/ PyTorch Software Documentation</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>Data</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/data.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="data">
<h1>Data<a class="headerlink" href="#data" title="Permalink to this headline">¶</a></h1>
<div class="section" id="converters">
<h2>Converters<a class="headerlink" href="#converters" title="Permalink to this headline">¶</a></h2>
<div class="section" id="module-rfml.data.converters.rml_2016">
<span id="rml2016"></span><h3>RML2016<a class="headerlink" href="#module-rfml.data.converters.rml_2016" title="Permalink to this headline">¶</a></h3>
<p>Data loaders for the RML2016.10x open source datasets provided by DeepSig, Inc.</p>
<dl class="function">
<dt id="rfml.data.converters.rml_2016.load_RML201610A_dataset">
<code class="sig-prename descclassname">rfml.data.converters.rml_2016.</code><code class="sig-name descname">load_RML201610A_dataset</code><span class="sig-paren">(</span><em class="sig-param">path: str = None</em><span class="sig-paren">)</span> &#x2192; rfml.data.dataset.Dataset<a class="reference internal" href="_modules/rfml/data/converters/rml_2016.html#load_RML201610A_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.converters.rml_2016.load_RML201610A_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Load the RadioML2016.10A Dataset provided by DeepSig Inc.</p>
<p>This dataset is licensed under Creative Commons Attribution - NonCommercial -
ShareAlike 4.0 License (CC BY-NC-SA 4.0) by DeepSig Inc.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>path</strong> (<em>str</em><em>, </em><em>optional</em>) – Path to the dataset which has already been downloaded from
DeepSig Inc., saved locally, and extracted (tar xjf).  If
not provided, the dataset will attempt to be downloaded
from the internet and saved locally – subsequent calls
would read from that cached dataset that is fetched.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> – If <em>path</em> is provided but does not exist.</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A Dataset that has been loaded with the data from RML2016.10A</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a></p>
</dd>
</dl>
<dl class="simple">
<dt>License</dt><dd><p><a class="reference external" href="https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode">https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode</a></p>
</dd>
<dt>Download Location</dt><dd><p><a class="reference external" href="https://www.deepsig.io/datasets">https://www.deepsig.io/datasets</a></p>
</dd>
<dt>Citation</dt><dd><p>T. J. O’Shea and N. West, “Radio machine learning dataset generation with GNU
Radio” in Proceedings of the GNU Radio Conference, vol. 1, 2016.</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="rfml.data.converters.rml_2016.load_RML201610B_dataset">
<code class="sig-prename descclassname">rfml.data.converters.rml_2016.</code><code class="sig-name descname">load_RML201610B_dataset</code><span class="sig-paren">(</span><em class="sig-param">path: str = None</em><span class="sig-paren">)</span> &#x2192; rfml.data.dataset.Dataset<a class="reference internal" href="_modules/rfml/data/converters/rml_2016.html#load_RML201610B_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.converters.rml_2016.load_RML201610B_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Load the RadioML2016.10B Dataset provided by DeepSig Inc.</p>
<p>This dataset is licensed under Creative Commons Attribution - NonCommercial -
ShareAlike 4.0 License (CC BY-NC-SA 4.0) by DeepSig Inc.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>path</strong> (<em>str</em><em>, </em><em>optional</em>) – Path to the dataset which has already been downloaded from
DeepSig Inc., saved locally, and extracted (tar xjf).  If
not provided, the dataset will attempt to be downloaded
from the internet and saved locally – subsequent calls
would read from that cached dataset that is fetched.</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> – If <em>path</em> is provided but does not exist.</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A Dataset that has been loaded with the data from RML2016.10B</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a></p>
</dd>
</dl>
<dl class="simple">
<dt>License</dt><dd><p><a class="reference external" href="https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode">https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode</a></p>
</dd>
<dt>Download Location</dt><dd><p><a class="reference external" href="https://www.deepsig.io/datasets">https://www.deepsig.io/datasets</a></p>
</dd>
<dt>Citation</dt><dd><p>T. J. O’Shea and N. West, “Radio machine learning dataset generation with GNU
Radio” in Proceedings of the GNU Radio Conference, vol. 1, 2016.</p>
</dd>
</dl>
</dd></dl>

</div>
</div>
<div class="section" id="module-rfml.data.dataset_builder">
<span id="dataset-builder"></span><h2>Dataset Builder<a class="headerlink" href="#module-rfml.data.dataset_builder" title="Permalink to this headline">¶</a></h2>
<p>Provide a builder pattern for the creation of a dataset.</p>
<dl class="class">
<dt id="rfml.data.dataset_builder.DatasetBuilder">
<em class="property">class </em><code class="sig-prename descclassname">rfml.data.dataset_builder.</code><code class="sig-name descname">DatasetBuilder</code><span class="sig-paren">(</span><em class="sig-param">n: int = None</em>, <em class="sig-param">keys: Set[str] = None</em>, <em class="sig-param">defaults: Dict[str</em>, <em class="sig-param">Union[str</em>, <em class="sig-param">int</em>, <em class="sig-param">float]] = {}</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/rfml/data/dataset_builder.html#DatasetBuilder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset_builder.DatasetBuilder" title="Permalink to this definition">¶</a></dt>
<dd><p>Builder pattern for programmatic creation of a Dataset</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n</strong> (<em>int</em><em>, </em><em>optional</em>) – Length of the time window (number of samples)
that each entry in the dataset should have.  If it is not
provided, then it is inferred from the first added example.
Defaults to None.</p></li>
<li><p><strong>keys</strong> (<em>Set</em><em>[</em><em>str</em><em>]</em><em>, </em><em>optional</em>) – A set of column headers that will
be included as metadata for all examples.  If it is not
provided, then it is inferred from the first added example.
Subsequent examples that are added must either have all of
these keys provided as metadata or they must be defined in
the defaults below. Defaults to None.</p></li>
<li><p><strong>defaults</strong> (<em>Dict</em><em>[</em><em>str</em><em>, </em><em>Union</em><em>, </em><em>optional</em>) – A mapping of default
metadata values that will be included for each example if
they aren’t overridden. Defaults to dict().</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">iq</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1024</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db</span> <span class="o">=</span> <span class="n">DatasetBuilder</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">iq</span><span class="p">,</span> <span class="n">Modulation</span><span class="o">=</span><span class="s2">&quot;BPSK&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">db</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">iq</span><span class="p">,</span> <span class="n">Modulation</span><span class="o">=</span><span class="s2">&quot;QPSK&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dataset</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">build</span><span class="p">()</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ValueError</strong> – If both keys and defaults are provided, but, the
    defaults have additional keys that were not provided.</p></li>
<li><p><strong>ValueError</strong> – If n is negative or 0.</p></li>
</ul>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>rfml.data.Dataset</p>
</div>
<dl class="method">
<dt id="rfml.data.dataset_builder.DatasetBuilder.add">
<code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param">iq: numpy.ndarray</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span> &#x2192; rfml.data.dataset_builder.DatasetBuilder<a class="reference internal" href="_modules/rfml/data/dataset_builder.html#DatasetBuilder.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset_builder.DatasetBuilder.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new example to the Dataset that is being built.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>iq</strong> (<em>np.ndarray</em>) – A (2xN) array of IQ samples.</p></li>
<li><p><strong>**kwargs</strong> – Each key=value pair is included as metadata for this
example.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>By returning the self, these calls can be chained.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#rfml.data.dataset_builder.DatasetBuilder" title="rfml.data.dataset_builder.DatasetBuilder">DatasetBuilder</a></p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>ValueError</strong> – If the IQ data does not match the expected shape – It
    should be (2xN) where N has been provided during construction of
    this builder or inferred from the first example added.</p></li>
<li><p><strong>ValueError</strong> – If all of the necessary metadata values are not provided
    in kwargs.  The necessary metadata values are either provided
    during construction of this builder or inferred from the first
    example added.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="rfml.data.dataset_builder.DatasetBuilder.build">
<code class="sig-name descname">build</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; rfml.data.dataset.Dataset<a class="reference internal" href="_modules/rfml/data/dataset_builder.html#DatasetBuilder.build"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset_builder.DatasetBuilder.build" title="Permalink to this definition">¶</a></dt>
<dd><p>Build the Dataset based on the examples that have been added.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>A compiled dataset consisting of the added examples.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-rfml.data.dataset">
<span id="dataset"></span><h2>Dataset<a class="headerlink" href="#module-rfml.data.dataset" title="Permalink to this headline">¶</a></h2>
<p>Wrap a premade dataset inside a Pandas DataFrame.</p>
<p>Provide a wrapper around a Pandas DataFrame for a premade dataset that splits
the classes and other distinguishing factors evenly for training, testing, and
validation sets.  Additionally, this module facilitates data loading from file
and transformation into the format needed by Keras and PyTorch.</p>
<p>By using Pandas masking functionality, this module can be used to subselect
parts of a dataset (e.g. only trained with no frequency offset, a subset of
modulatons, etc.)</p>
<dl class="class">
<dt id="rfml.data.dataset.Dataset">
<em class="property">class </em><code class="sig-prename descclassname">rfml.data.dataset.</code><code class="sig-name descname">Dataset</code><span class="sig-paren">(</span><em class="sig-param">df: pandas.core.frame.DataFrame</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/rfml/data/dataset.html#Dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset.Dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Provide a wrapper around a Pandas DataFrame containing a dataset.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>df</strong> (<em>pd.DataFrame</em>) – Pandas DataFrame that represents the dataset</p>
</dd>
</dl>
<dl class="method">
<dt id="rfml.data.dataset.Dataset.as_numpy">
<code class="sig-name descname">as_numpy</code><span class="sig-paren">(</span><em class="sig-param">le: rfml.data.encoder.Encoder</em>, <em class="sig-param">mask: pandas.core.generic.NDFrame.mask = None</em><span class="sig-paren">)</span> &#x2192; Tuple[numpy.ndarray, numpy.ndarray]<a class="reference internal" href="_modules/rfml/data/dataset.html#Dataset.as_numpy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset.Dataset.as_numpy" title="Permalink to this definition">¶</a></dt>
<dd><p>Encode the Dataset as a machine learning &lt;X, Y&gt; pair in NumPy format.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>le</strong> (<a class="reference internal" href="#rfml.data.encoder.Encoder" title="rfml.data.encoder.Encoder"><em>Encoder</em></a>) – Label encoder used to translate the label column into
a format the neural network will understand (such as an index).  The
label column is embedded within this class.</p></li>
<li><p><strong>mask</strong> (<em>pd.DataFrame.mask</em><em>, </em><em>optional</em>) – Mask to apply before creating
the Machine Learning pairs. Defaults to None.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>x, y</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Tuple[np.ndarray, np.ndarray]</p>
</dd>
</dl>
<p>The X matrix is returned in the format (batch, channel, iq, time).
The Y matrix is returned in the format (batch).</p>
<p>Batch corresponds to the number of examples in the dataset, channel is
always 1, IQ is always 2, and time is variable length depending on how
the underlying data has been sliced.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Numpy is the format used by Keras.  Other machine learning
frameworks (such as PyTorch) require a separate method for getting
the data ready.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>rfml.data.Encoder,
rfml.data.Dataset.as_torch</p>
</div>
</dd></dl>

<dl class="method">
<dt id="rfml.data.dataset.Dataset.as_torch">
<code class="sig-name descname">as_torch</code><span class="sig-paren">(</span><em class="sig-param">le: rfml.data.encoder.Encoder</em>, <em class="sig-param">mask: pandas.core.generic.NDFrame.mask = None</em><span class="sig-paren">)</span> &#x2192; torch.utils.data.dataset.TensorDataset<a class="reference internal" href="_modules/rfml/data/dataset.html#Dataset.as_torch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset.Dataset.as_torch" title="Permalink to this definition">¶</a></dt>
<dd><p>Encode the Dataset as machine learning &lt;X, Y&gt; pairs in PyTorch
format.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>le</strong> (<a class="reference internal" href="#rfml.data.encoder.Encoder" title="rfml.data.encoder.Encoder"><em>Encoder</em></a>) – Label encoder used to translate the label column into
a format the neural network will understand (such as an index).  The
label column is embedded within this class.</p></li>
<li><p><strong>mask</strong> (<em>pd.DataFrame.mask</em><em>, </em><em>optional</em>) – Mask to apply before creating
the Machine Learning pairs. Defaults to None.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Dataset to be used in training or testing loops.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>TensorDataset</p>
</dd>
</dl>
<p>The X matrix is returned in the format (batch, channel, iq, time).
The Y matrix is returned in the format (batch).</p>
<p>Batch corresponds to the number of examples in the dataset, channel is
always 1, IQ is always 2, and time is variable length depending on how
the underlying data has been sliced.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>TensorDataset is the format used by PyTorch and allows for iteration
in batches.  For other machine learning frameworks, such as Keras,
ensure you call the correct method.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>rfml.data.Encoder,
rfml.data.Dataset.as_numpy</p>
</div>
</dd></dl>

<dl class="method">
<dt id="rfml.data.dataset.Dataset.columns">
<em class="property">property </em><code class="sig-name descname">columns</code><a class="headerlink" href="#rfml.data.dataset.Dataset.columns" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of the columns that are represented in the underlying Dataframe</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Column names</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>List[str]</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="rfml.data.dataset.Dataset.df">
<em class="property">property </em><code class="sig-name descname">df</code><a class="headerlink" href="#rfml.data.dataset.Dataset.df" title="Permalink to this definition">¶</a></dt>
<dd><p>Directly return the underlying Pandas DataFrame containing the data.</p>
<p>This can then be used for mask creation.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Pandas DataFrame that represents the dataset</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>pd.DataFrame</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="rfml.data.dataset.Dataset.get_examples_per_class">
<code class="sig-name descname">get_examples_per_class</code><span class="sig-paren">(</span><em class="sig-param">label: str = 'Modulation'</em><span class="sig-paren">)</span> &#x2192; Dict[str, int]<a class="reference internal" href="_modules/rfml/data/dataset.html#Dataset.get_examples_per_class"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset.Dataset.get_examples_per_class" title="Permalink to this definition">¶</a></dt>
<dd><p>Count the number of examples per class in this Dataset.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>label</strong> (<em>str</em><em>, </em><em>optional</em>) – Column that is used as the class label.
Defaults to “Modulation”.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Count of examples (value) per label (key).</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Dict[str, int]</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="rfml.data.dataset.Dataset.is_balanced">
<code class="sig-name descname">is_balanced</code><span class="sig-paren">(</span><em class="sig-param">label: str = 'Modulation'</em>, <em class="sig-param">margin: int = 0</em><span class="sig-paren">)</span> &#x2192; bool<a class="reference internal" href="_modules/rfml/data/dataset.html#Dataset.is_balanced"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset.Dataset.is_balanced" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the data contained in this dataset is evenly represented by
a categorical label.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>label</strong> (<em>str</em><em>, </em><em>optional</em>) – The column of the data to verify is balanced.
Defaults to “Modulation”.</p></li>
<li><p><strong>margin</strong> (<em>int</em><em>, </em><em>optional</em>) – Difference between the expected balance and
the true balance before this check would fail.  This can be
useful for checking for a “fuzzy balance” that would occur if
the Dataset was previously split and therefore the length of the
Dataset is no longer divisible by the number of categorical
labels. Defaults to 0.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>True if the Dataset is balanced, False otherwise.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="rfml.data.dataset.Dataset.split">
<code class="sig-name descname">split</code><span class="sig-paren">(</span><em class="sig-param">frac: float = 0.3</em>, <em class="sig-param">on: Tuple[str] = None</em>, <em class="sig-param">mask: pandas.core.generic.NDFrame.mask = None</em><span class="sig-paren">)</span> &#x2192; Tuple[rfml.data.dataset.Dataset, rfml.data.dataset.Dataset]<a class="reference internal" href="_modules/rfml/data/dataset.html#Dataset.split"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.dataset.Dataset.split" title="Permalink to this definition">¶</a></dt>
<dd><p>Split this Dataset into two based on fractional availability.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>frac</strong> (<em>float</em><em>, </em><em>optional</em>) – Percentage of the Dataset to put into the
second set. Defaults to 0.3.</p></li>
<li><p><strong>on</strong> (<em>Tuple</em><em>[</em><em>str</em><em>]</em><em>, </em><em>optional</em>) – Collection of column names, with
categorical values, to evenly split amongst the two Datasets.
If provided, each categorical value will have an equal
percentage representation in the returned Dataset. Defaults to
None.</p></li>
<li><p><strong>mask</strong> (<em>pd.DataFrame.mask</em><em>, </em><em>optional</em>) – Mask to apply before performing
the split. Defaults to None.</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> – If <em>frac</em> is not between (0, 1)</p>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Two Datasets (such as train/validate)</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>Tuple[<a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a>, <a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a>]</p>
</dd>
</dl>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Not providing anything for the <em>on</em> parameter may lead to incorrect
behavior.  For instance, you may have a class imbalance in the
datasets.  This may be desired in some cases, but, its likely one
would want to explicitly specify this and not rely on randomness.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p>Dataset.subsample</p>
</div>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-rfml.data.encoder">
<span id="encoder"></span><h2>Encoder<a class="headerlink" href="#module-rfml.data.encoder" title="Permalink to this headline">¶</a></h2>
<p>Simple helper class for encoding/decoding the labels for classification</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>While many packages like sklearn and keras provide similar functionality,
they were all quite annoying and did not play well with others.  Since this
functionality is so simple, its easier to just write our own implementation.</p>
</div>
<dl class="class">
<dt id="rfml.data.encoder.Encoder">
<em class="property">class </em><code class="sig-prename descclassname">rfml.data.encoder.</code><code class="sig-name descname">Encoder</code><span class="sig-paren">(</span><em class="sig-param">labels: Tuple[str], label_name: str</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/rfml/data/encoder.html#Encoder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.encoder.Encoder" title="Permalink to this definition">¶</a></dt>
<dd><p>Encode the labels as an index of the “one-hot” which is used by PyTorch.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>labels</strong> (<em>Tuple</em><em>[</em><em>str</em><em>]</em>) – A collection of human readable labels that could be
encountered</p></li>
<li><p><strong>label_name</strong> (<em>str</em>) – Name of the label column in the dataset that is being
categorically encoded.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="s2">&quot;WBFM&quot;</span> <span class="o">-&gt;</span> <span class="mi">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s2">&quot;QAM16&quot;</span> <span class="o">-&gt;</span> <span class="mi">6</span>
</pre></div>
</div>
<dl class="method">
<dt id="rfml.data.encoder.Encoder.decode">
<code class="sig-name descname">decode</code><span class="sig-paren">(</span><em class="sig-param">encoding: Tuple[int]</em><span class="sig-paren">)</span> &#x2192; Tuple[str]<a class="reference internal" href="_modules/rfml/data/encoder.html#Encoder.decode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.encoder.Encoder.decode" title="Permalink to this definition">¶</a></dt>
<dd><p>Decode a list of machine readable labels into human readable labels.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>encoding</strong> (<em>Tuple</em><em>[</em><em>int</em><em>]</em>) – A collection of machine readable labels.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A collection of human readable labels.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Tuple[str]</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="rfml.data.encoder.Encoder.encode">
<code class="sig-name descname">encode</code><span class="sig-paren">(</span><em class="sig-param">labels: Tuple[str]</em><span class="sig-paren">)</span> &#x2192; Tuple[int]<a class="reference internal" href="_modules/rfml/data/encoder.html#Encoder.encode"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.encoder.Encoder.encode" title="Permalink to this definition">¶</a></dt>
<dd><p>Encode a list of human readable labels into machine readable labels.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>labels</strong> (<em>Tuple</em><em>[</em><em>str</em><em>]</em>) – Human readable labels to encode.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>A collection of machine readable labels.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>Tuple[int]</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="rfml.data.encoder.Encoder.label_name">
<em class="property">property </em><code class="sig-name descname">label_name</code><a class="headerlink" href="#rfml.data.encoder.Encoder.label_name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the column in the dataset that is categorically encoded by this
class.</p>
</dd></dl>

<dl class="method">
<dt id="rfml.data.encoder.Encoder.labels">
<em class="property">property </em><code class="sig-name descname">labels</code><a class="headerlink" href="#rfml.data.encoder.Encoder.labels" title="Permalink to this definition">¶</a></dt>
<dd><p>A collection of human readable labels that could be encountered –
This allows the extraction of these labels by another object in order
to plot or log.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-rfml.data.factory">
<span id="factory"></span><h2>Factory<a class="headerlink" href="#module-rfml.data.factory" title="Permalink to this headline">¶</a></h2>
<p>Simplistic factory pattern for swapping of datasets.</p>
<dl class="function">
<dt id="rfml.data.factory.build_dataset">
<code class="sig-prename descclassname">rfml.data.factory.</code><code class="sig-name descname">build_dataset</code><span class="sig-paren">(</span><em class="sig-param">dataset_name: str</em>, <em class="sig-param">test_pct: float = 0.3</em>, <em class="sig-param">val_pct: float = 0.05</em>, <em class="sig-param">path: str = None</em><span class="sig-paren">)</span> &#x2192; Tuple[rfml.data.dataset.Dataset, rfml.data.dataset.Dataset, rfml.data.dataset.Dataset, rfml.data.encoder.Encoder]<a class="reference internal" href="_modules/rfml/data/factory.html#build_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#rfml.data.factory.build_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Opinionated factory method that allows easy loading of different datasets.</p>
<p>This method makes an assumption about the labels to use for each dataset – if you
need more extensive control then you can call the underlying method directly.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dataset_name</strong> (<em>str</em>) – Name of the dataset to load.  Currently supported values
are:
- RML2016.10A
- RML2016.10B</p></li>
<li><p><strong>test_pct</strong> (<em>float</em><em>, </em><em>optional</em>) – Percentage of the entire Dataset that should be
withheld as a test set. Defaults to 0.3.</p></li>
<li><p><strong>val_pct</strong> (<em>float</em><em>, </em><em>optional</em>) – Percentage of the non-testing Dataset that should be
split out to use for validation in an early stopping
procedure. Defaults to 0.05.</p></li>
<li><p><strong>path</strong> (<em>str</em><em>, </em><em>optional</em>) – If provided, this is directly passed to the dataset
converters so that they do not download the dataset from
the internet (a costly operation) if you have already
downloaded it yourself. Defaults to None.</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><ul class="simple">
<li><p><strong>ValueError</strong> – If test_pct or val_pct are not between 0 and 1 (non-inclusive).</p></li>
<li><p><strong>ValueError</strong> – If the dataset_name is unknown.</p></li>
</ul>
</dd>
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>train, validation, test, encoder</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>Tuple[<a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a>, <a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a>, <a class="reference internal" href="#rfml.data.dataset.Dataset" title="rfml.data.dataset.Dataset">Dataset</a>, <a class="reference internal" href="#rfml.data.encoder.Encoder" title="rfml.data.encoder.Encoder">Encoder</a>]</p>
</dd>
</dl>
</dd></dl>

</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="nbutils.html" class="btn btn-neutral float-right" title="Notebook Utilities" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="index.html" class="btn btn-neutral float-left" title="Welcome to RFML with PyTorch’s documentation!" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Bryse Flowers

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>